<template>
  <div>
    <div class="form-group">
      <label class="col-sm-12 control-label">
        <img src="../../../static/optionright.png" width="25" height="25"></img>&nbsp;
        检查说明</label>
      <div class="col-sm-12">
        <ol>
          <li>已对客户燃气设施进行了安全检查</li>
          <li>已对客户进行了安全知识宣传，并发放宣传资料</li>
          <li>已对客户的资料进行了登记</li>
          <li>已对违章及隐患之客户下发隐患整改告知书</li>
        </ol>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-12 control-label">
        <img src="../../../static/optionright.png" width="25" height="25"></img>&nbsp;
        总体安检照片1：</label>
      <div class="col-sm-12">
        <img :class="style__" @click="takePic('f_overall_path', '总体安检照片')"  :src="f_overall_path" alt="总体安检照片" width="150" height="200">
        &nbsp;&nbsp;&nbsp;&nbsp;<span :class="style__" class="glyphicon glyphicon-trash" @click="delfile('f_overall_path', this.f_overall_path)"></span>
        &nbsp;&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-picture" @click="this.$parent.$parent.viewPic(this.f_overall_path)"></span>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-12 control-label">
        <img src="../../../static/optionright.png" width="25" height="25"></img>&nbsp;
        总体安检照片2：</label>
      <div class="col-sm-12">
        <img :class="style__" @click="takePic('f_overall2_path', '总体安检照片2')"  :src="f_overall2_path" alt="总体安检照片2" width="150" height="200">
        &nbsp;&nbsp;&nbsp;&nbsp;<span :class="style__" class="glyphicon glyphicon-trash" @click="delfile('f_overall2_path', this.f_overall2_path)"></span>
        &nbsp;&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-picture" @click="this.$parent.$parent.viewPic(this.f_overall2_path)"></span>
      </div>
    </div>
    <div :class="style__" class="form-group">
      <label class="col-sm-12 control-label">
        <img src="../../../static/optionright.png" width="25" height="25"></img>&nbsp;
        安检通知书/隐患整改通知书</label>
      <div class="col-sm-12">
          <input type="checkbox" v-model="f_defect_notified">安检通知书/隐患整改通知书</input>
      </div>
    </div>
    <div class="form-group" v-show="f_defect_notified">
      <label class="col-sm-12 control-label">
        <img src="../../../static/optionright.png" width="25" height="25"></img>&nbsp;
        安检通知书/隐患整改通知书照片(要求能清晰反应安检通知单和用户签字内容)：</label>
      <div class="col-sm-12">
        <img :class="style__" @click="takePic('f_notified_path', '安检通知书/隐患整改通知书照片')"  :src="f_notified_path" alt="安检通知书/隐患整改通知书照片" width="150" height="200">
        &nbsp;&nbsp;&nbsp;&nbsp;<span :class="style__" class="glyphicon glyphicon-trash" @click="delfile('f_notified_path', this.f_notified_path)"></span>
        &nbsp;&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-picture" @click="this.$parent.$parent.viewPic(this.f_notified_path)"></span>
      </div>
    </div>
    <div :class="style__" class="form-group">
      <label class="col-sm-12 control-label">
        <img src="../../../static/optionright.png" width="25" height="25"></img>&nbsp;
        请对我们的服务做出评价：</label>
      <div class="col-sm-12">
        <radio-group :value.sync="f_client_evaluation" type="success" buttons="false">
          <radio value="满意">满意</radio>
          <radio value="基本满意">基本满意</radio>
          <radio value="不满意">不满意</radio>
        </radio-group>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-12 control-label">
        <img src="../../../static/optionright.png" width="25" height="25"></img>&nbsp;
        反馈录音</label>
      <div class="col-sm-12">
        <span v-show="f_recording1_path">已录音</span>
        <img src="../../assets/clip.jpg" @click="record"></img>
        &nbsp;&nbsp;&nbsp;&nbsp;<span :class="style__" class="glyphicon glyphicon-trash" @click="delAudioFile('f_recording1_path', this.f_recording1_path)"></span>
      </div>
    </div>
    <div style="height:50px;"></div>
  </div>
</template>

<script>
import Vue from 'vue'
import * as Util from '../Util'
export default {
  title: '用户反馈',
  data() {
    return this.$parent.$parent.data
  },
  props: ['idx'],
  methods: {
    cameraCallBack(prop, fileName) {
        HostApp.__this__.$set(prop, fileName + '?' + Math.random())
        HostApp.__callback__ = null
        HostApp.__this__ = null
    },
    takePic(prop, title) {
      HostApp.__callback__ = this.cameraCallBack
      HostApp.__this__ = this
      console.log("prop:" + prop)
      console.log("this.prop:" + this[prop])
      let fileName
      if(!this[prop] || this[prop].includes("nopic.png")) {
        fileName = Util.guid() +'-' + prop + '.jpg'
      } else {
        fileName = Util.getFileName(this[prop])
      }
      HostApp._open_a_page({type: 'boomerang',
        page: 'com.aofeng.hybrid.android.peripheral.CameraActivity',
        param: {file: fileName, requestCode: 111, callback:'javascript:HostApp.__callback__("' + prop +'", "%s");', watermark: title + '\t时间：'+ Util.toStandardTimeString() + '\t' + Vue.user.name}
      })
    },
    amrCallBack(fileName) {
        HostApp.__this__.$set('f_recording1_path', fileName)
        HostApp.__callback__ = null
        HostApp.__this__ = null
    },
    record() {
      if(this.$parent.$parent.role == 'view') {
        window.location = this.f_recording1_path
      } else {
        HostApp.__callback__ = this.amrCallBack
        HostApp.__this__ = this
        let fileName
        if(!this.f_recording1_path) {
          fileName = Util.guid() + '.amr'
        } else {
          fileName = Util.getFileName(this.f_recording1_path)
        }
        HostApp._open_a_page({type: 'boomerang',
          page: 'com.aofeng.hybrid.android.peripheral.AudioClipActivity',
          param: {file: fileName, requestCode: 111, callback:'javascript:HostApp.__callback__("%s");'}
        })
      }
    },
    delfile(prop, fileName) {
      if(fileName == Vue.nopic)
        return
      else {
        HostApp.delfile(fileName)
        this[prop] = Vue.nopic
      }
    },
    delAudioFile(prop, fileName) {
      if(!fileName)
        return
      else {
        HostApp.delfile(fileName)
        this[prop] = null
      }
    }
  },
  ready() {
    if(!this.f_notified_path)
      this.$set('f_notified_path', Vue.nopic)
    if(!this.f_signature_path)
      this.$set('f_signature_path', Vue.nopic)
    if(!this.f_overall_path)
      this.$set('f_overall_path', Vue.nopic)
    if(!this.f_overall2_path)
      this.$set('f_overall2_path', Vue.nopic)
  }
}
</script>
